/*
 * @Descripttion: 
 * @version: 
 * @Author: mmzhang
 * @Date: 2021-07-27 16:02:34
 * @LastEditTime: 2022-06-14 13:27:05
 */
import table from '@/components/dt/table/render.js'
import nameOpt from '@/biz/option/name.js'
import dateOpt from '@/biz/option/date.js'
import Opt from '@/components/dt/info/Opt.js'
import dt from '@dt/dt'
import clueMgr from '@/biz/businessReport/clue'
import CustomerMgr from '@/biz/customer/customerOpt.js'

let _this = null

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [

      {
        title: '购买人',
        field: 'purchaseUser',
        minWidth: 150,
        slots: {
          header: (params, h) => {
            return table.header.arrow(_this, h, nameOpt.createPeople({
              key: 'userId',
              title: '购买人',
              to: (info) => {
                return {
                  userId: info.userId,

                }
              }
            }))
          },

        }
      },
      {
        title: '绑定手机号',
        field: 'userPhone',
        minWidth: 200,
      },
      {
        field: 'phoneX',
        minWidth: 130,
        header: {
          filter: {
            title: '隐私号',
            key: 'phoneX',
            placeholder: '请输入手机号码',
            input: {}
          }
        }
      }, {
        title: '购买租用天数',
        field: 'leaseDay',
        minWidth: 200,
      }, {
        title: '购买通话时间',
        field: 'talkTime',
        minWidth: 200,
      },
      {
        field: 'createTime',
        minWidth: 150,
        title: '购买时间',
        header: {
          filter: dateOpt.range({
            title: '购买时间',
            startKey: 'statTime',
            endKey: 'endTime',
            disabled: (date) => {
              return date.valueOf() > new Date().getTime()
            },
            check: (val) => {
              if (_this.$tool.dateDiff(val.statTime, val
                  .endTime).Y >= 2) {
                // 日期最大跨度两年
                _this.$Message.warning('签约日期跨度至多两年。')
              }
              return !(_this.$tool.dateDiff(val.statTime, val
                .endTime).Y >= 2)
            }
          }),
        },
      },
      {
        title: '配置人',
        field: 'createUser',
        minWidth: 200,
      },
    ]
  }

}

export default Column